<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/site.css">
</head>
<body>

<c:if test="${requestScope.emps == null }">
	<jsp:forward page="emp.do?action=search"></jsp:forward>
</c:if>

<jsp:include page="header.jsp"></jsp:include>
<jsp:include page="menu.jsp"></jsp:include>

<div class="container">
	<h1>员工列表</h1>
	
	<form action="emp.do?action=search" method="post">
		姓名:<input type="text" name="ename">
		电话:<input type="text" name="ephone">
		部门:<select name="did">
			<option value="">请选择部门</option>
			<c:forEach items="${requestScope.depts }" var="dept">
				<option value="${dept.did }">${dept.dname }</option>
			</c:forEach>
		</select>
		<input type="submit" value="搜索">
	</form><br>
	
	<table border="1px" width="100%">
		<tr>
			<th>ID</th>
			<th>姓名</th>
			<th>头像</th>
			<th>电话</th>
			<th>生日</th>
			<th>部门</th>
			<th>操作</th>
		</tr>
		
		<c:if test="${requestScope.emps == null }">
			<jsp:forward page="emp.do?action=search"></jsp:forward>
		</c:if>
		
		<c:forEach items="${requestScope.emps }" var="emp">
			<tr>
				<td>${emp.eid }</td>
				<td>${emp.ename }</td>
				<td>
					<c:if test="${emp.ephoto!=null }">
						<img src="upload/${emp.ephoto }" width="50px">
					</c:if>
					<%-- <a href="uploadPhotos.jsp?eid=${emp.eid} ">
						<c:if test="${emp == null }">
							<img src="img/photo_001.png" width="50px">
						</c:if>
						<c:if test="${emp != null }">
							<img src="upload/${emp.ephoto }" width="50px">
						</c:if>
					</a>  --%>
				</td>
				<td>${emp.ephone }</td>
				<td><fmt:formatDate value="${emp.ebirthday }" pattern="yyyy年MM月dd日"/></td>
				<td>${emp.dname }</td>
				<td>
					<a href="">修改</a>
					<a href="emp.do?action=remove&eid=${emp.eid}">删除</a>
				</td>
			</tr>
		</c:forEach>
		
	</table>
</div>
</body>
</html>